<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="/wondershare/js/jquery.js"></script> 
<script src="/wondershare/js/ad.js"></script>
<script src="/wondershare/js/jquery.cvbox.min.js"></script> 
<link href="/wondershare/styles/main.css" rel="stylesheet" type="text/css" />
<link href="/wondershare/styles/general.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../images/unti.js"></script>
<title>广告<{$title}>页</title>
<script>
//判断广告名称是否相同
function  isNameExist() {
	$.get("http://cms.wondershare.com/wondershare/ad.php?action=ajaxAd&w_type=<{$w_type}>", 
			{ad_name: $("#ad_name").val(), type: 'is_name_exist', ad_id: $("#ad_id").val()}, 
	function(data) {
	
		if (data >0) {
			 alert('广告名称已经存在库中，请重新录入！');
			$("#ad_name").focus();
			return false;
		}
	});
}


$(document).ready(function(){
	$("#ad_name").blur(function() {
	 	isNameExist();
	});
}); 

//表单提交
function checkSubmit() {

	var ad_name = $('#ad_name').val().replace(/(^\s*)|(\s*$)/g, "");
	var ad_size = $('#ad_size').val().replace(/(^\s*)|(\s*$)/g, "");
	var ad_photo = $('#ad_photo').val().replace(/(^\s*)|(\s*$)/g, "");
	var ad_url = $('#ad_url').val().replace(/(^\s*)|(\s*$)/g, "");
	
	if (ad_name == "" ) {
		
		alert('广告名称不能为空！');
		$("#ad_name").focus();
		return false;
	}
	
	if (ad_name != "") {
		return isNameExist();
	}
	
	if (ad_size == "") {
		alert('广告尺寸不能为空！');
		$("#ad_size").focus();
		return false;
	} else {
		
		var patrn =  /^[0-9]{1,4}\*[0-9]{1,4}$/;
		if (!patrn.exec(ad_size)) {
			alert('广告尺寸不正确！');
			$("#ad_size").focus();
			return false;
		}
	
	}
	
	if ( ad_photo != "") {
		
		str = ad_photo.match(/http:\/\/.+/); 
		if (str == null) {
			alert('你输入的广告图片URL无效');
			$("#ad_photo").focus(); 
			return false;
		}
	
	}
	
	if (ad_url != "") {
		
		str = ad_url.match(/http:\/\/.+/); 
		if (str == null) {
			alert('你输入的广告登陆页面URL无效');
			$("#ad_url").focus(); 
			return false;
		}
	}
	return true;
}
</script>
</head>
<body>
    <h1>
        <span class="action-span1">
        	<a href="http://cms.wondershare.com/wondershare/ad.php?action=index&w_type=<{$w_type}>"><{$web_info}>广告管理</a>
        </span> 
        <span id="search_id" class="action-span1"> > <{$title}>广告</span>
        <div style="clear:both"></div>
    </h1>
    <div id="tabbody-div"  style=" width:1100px;">
        <form  name="theForm" method="post" action="/wondershare/ad.php?action=addEdit&w_type=<{$w_type}>" onsubmit="return checkSubmit();">
            <table align="center" width="90%" id="general-table">
                <tbody>
                    <tr>
                        <td class="label">*广告名称：</td>
                        <td>
                        <input type="text" size="60" style="float:left;color:;" value="<{$ad_info.ad_name}>" name="ad_name" id="ad_name"> 
                        </td>
                    </tr>
                    <tr>
                        <td class="label">*广告尺寸：</td>
                        <td>
                        <input type="text" size="60" style="float:left;color:;" value="<{$ad_info.ad_size}>" name="ad_size" id="ad_size">&nbsp;&nbsp; 
                        <span style="color:#FF0000">如200*200这样的尺寸,宽和高不大于10000</span>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">广告备注：</td>
                        <td>
                        <input type="text" size="60" style="float:left;color:;" value="<{$ad_info.ad_remark}>" name="ad_remark" id="ad_remark">
                        </td>
                        </tr>
                    <tr>
                        <td class="label">广告图片URL：</td>
                        <td>
                        <input type="text" size="60" style="float:left;color:;" value="<{$ad_info.ad_photo}>" name="ad_photo" id="ad_photo"> 
                        </td>
                    </tr>
                    <tr>
                        <td class="label">广告图片Alt标签：</td>
                        <td>
                        <input type="text" size="60" style="float:left;color:;" value="<{$ad_info.ad_alt}>" name="ad_alt" id="ad_alt">
                        </td>
                    </tr>
                    <tr>
                        <td class="label">广告登陆页面：</td>
                        <td>
                        <input type="text" size="60" style="float:left;color:;" value="<{$ad_info.ad_url}>" name="ad_url" id="ad_url">
                        </td>
                    </tr>
                    <tr>
                        <td class="label">整合类广告内容：<br /><br />(HasOffers系统广告代码)</td>
                        <td>
                         <textarea cols="60" rows="6" id="ad_content" name="ad_content"><{$ad_info.ad_content}></textarea>
                        </td>
                    </tr>   
                    <tr>
                        <td class="label">广告投放位置：</td>
                        <td>
                            <textarea cols="60" rows="6" id="delivery_content" name="delivery_content" 
                            disabled="delivery_content" wrap="on" ><{$ad_info.delivery_content}></textarea>
                            <input type="button" value="选择投放"  name="get_delivery"  style="margin-left:20px; margin-top:10px; " 
                            onclick="get_ad_position_list('delivery_list');"  />
                        </td>
                    </tr>      
                
                </tbody>
            </table>
            
            <div  style="margin-left:380px; margin-top:20px;">
                <input type="hidden"  name="ad_id" id="ad_id" value="<{$ad_info.ad_id}>">
                <input type="hidden"  id="w_type" name="w_type" value="<{$w_type}>" >
                <input type="hidden" id="new_group_position" name="new_group_position"  value="<{$new_group_position}>" >
                <input name="old_group_position" id="old_group_position"  type="hidden" value="<{$old_group_position}>"/>
                
                <input type="submit"   class="button" value=" <{$title}> " name="sub_from">
                <input type="reset" class="button" value=" 重置 ">
            </div>
                <input type="hidden" value="<{$form_act}>" name="act" >
        </form>
    </div>
</body>
</html>